package com.pig4cloud.pig.module.service.estate.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.pig.module.api.entity.estate.RepairRecordImg;
import com.pig4cloud.pig.module.mapper.estate.RepairRecordImgMapper;
import com.pig4cloud.pig.module.service.estate.IRepairRecordImgService;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Value;

import javax.annotation.Resource;
import java.util.List;

@Service
public class RepairRecordImgServiceImpl extends ServiceImpl<RepairRecordImgMapper, RepairRecordImg> implements IRepairRecordImgService {
    @Resource
    private RepairRecordImgMapper repairRecordImgMapper;
//
    @Value("${ruoyi.imgUrl}")
    private String imgUrl;//图片地址

//	@Value("${ruoyi.imgUrlOss}")
//	private String imgUrlOss;


    @Override
    public List<RepairRecordImg> getListByRecordId(int recordId) {
        List<RepairRecordImg> imgs = repairRecordImgMapper.selectListByColumn("record_id",recordId);
        if(imgs!=null && imgs.size() > 0){
            for(RepairRecordImg img : imgs){
                if(img!=null){
                    String img_key = img.getImgUrl()!=null ? img.getImgUrl() : "";
                    if(!img_key.equals("")){
                        img.setImgUrl(imgUrl + img_key);
                    }
                }
            }
        }
        return imgs;
    }
}
